extern crate rand;
use rand::prelude::*;

use std::ops::Range;

use rand::Rng;

pub fn random_idx(high: usize) -> usize {
    let mut rng = thread_rng();
    rng.gen_range(0..high) as usize
}

pub fn random_array(size: usize, range: Range<i32>) -> Vec<i32> {
    let rng = thread_rng();
    let distr = rand::distributions::Uniform::from(range);
    rng.sample_iter(distr).take(size).collect()
}

pub fn random_i32(min_v: i32, max_v: i32) -> i32 {
    let mut rng = rand::thread_rng();
    rng.gen::<i32>();
    rng.gen_range(min_v..max_v)
}
